winsafe\ole\com_interfaces/
ipersiststream.rs

1#![allow(non_camel_case_types, non_snake_case)]
2
3use crate::decl::*;
4use crate::ole::{privs::*, vts::*};
5use crate::prelude::*;
6
7com_interface! { IPersistStream: "00000109-0000-0000-c000-000000000046";
8	/// [`IPersistStream`](https://learn.microsoft.com/en-us/windows/win32/api/objidl/nn-objidl-ipersiststream)
9	/// COM interface.
10	///
11	/// Automatically calls
12	/// [`Release`](https://learn.microsoft.com/en-us/windows/win32/api/unknwn/nf-unknwn-iunknown-release)
13	/// when the object goes out of scope.
14}
15
16impl ole_IPersist for IPersistStream {}
17impl ole_IPersistStream for IPersistStream {}
18
19/// This trait is enabled with the `ole` feature, and provides methods for
20/// [`IPersistStream`](crate::IPersistStream).
21///
22/// Prefer importing this trait through the prelude:
23///
24/// ```no_run
25/// use winsafe::prelude::*;
26/// ```
27pub trait ole_IPersistStream: ole_IPersist {
28	/// [`IPersistStream::GetSizeMax`](https://learn.microsoft.com/en-us/windows/win32/api/objidl/nf-objidl-ipersiststream-getsizemax)
29	/// method.
30	#[must_use]
31	fn GetSizeMax(&self) -> HrResult<u64> {
32		let mut max = 0u64;
33		ok_to_hrresult(unsafe { (vt::<IPersistStreamVT>(self).GetSizeMax)(self.ptr(), &mut max) })
34			.map(|_| max)
35	}
36
37	/// [`IPersistStream::IsDirty`](https://learn.microsoft.com/en-us/windows/win32/api/objidl/nf-objidl-ipersiststream-isdirty)
38	/// method.
39	#[must_use]
40	fn IsDirty(&self) -> HrResult<bool> {
41		okfalse_to_hrresult(unsafe { (vt::<IPersistStreamVT>(self).IsDirty)(self.ptr()) })
42	}
43
44	/// [`IPersistStream::Load`](https://learn.microsoft.com/en-us/windows/win32/api/objidl/nf-objidl-ipersiststream-load)
45	/// method.
46	fn Load(&self, stream: &impl ole_IStream) -> HrResult<()> {
47		ok_to_hrresult(unsafe { (vt::<IPersistStreamVT>(self).Load)(self.ptr(), stream.ptr()) })
48	}
49
50	/// [`IPersistStream::Save`](https://learn.microsoft.com/en-us/windows/win32/api/objidl/nf-objidl-ipersiststream-save)
51	/// method.
52	fn Save(&self, stream: &impl ole_IStream, clear_dirty: bool) -> HrResult<()> {
53		ok_to_hrresult(unsafe {
54			(vt::<IPersistStreamVT>(self).Save)(self.ptr(), stream.ptr(), clear_dirty as _)
55		})
56	}
57}